<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #box{
      width: 200px;
      height: 200px;
      background-color: rgb(135, 192, 97);
      margin: 10px auto;
    }
  </style>
</head>
<body>
  <button>隐藏</button>
  <div id="box"></div>
  <script>
      var btn = document.querySelector('button');
      var box = document.querySelector('#box');
      btn.onclick = function(){
        if(!this.isShow){
          box.style.display = 'none';
          this.innerHTML = "显示";
          this.isShow = !this.isShow;
        }else{
          box.style.display = 'block';
          this.innerHTML = "隐藏";
          this.isShow = !this.isShow;
        }
      }
  </script>
</body>
</html>